let testString = 'Hello World';
testString = '大前端'

const constantString = 'Hello World';
// constantString = '';

let x: 'hello' = 'hello';
// x = 'world' // 报错，x只能是hello

function printText(s: string, alignment: 'left' | 'right' | 'center') {

}

printText('hello', 'left');
// printText('hello', 'center2'); // 报错

function compare(a: string, b: string): -1 | 0 | 1 {
    return a === b ? 0 : a > b ? 1 : -1
}

interface Options {
    width: number
}

function configure(x: Options | 'auto') {

}

configure({
    width: 100
})

configure('auto')
// configure('automatic') 报错，参数未定义automatic类型

let b1: true = true; // 值只能是true
let b2: false = false;   // 值只能是false

const obj1 = {
    count: 0
}

if (true) {
    obj1.count = 1
}

function handleRequest(url: string, method: 'GET' | 'POST' | 'GUESS') {

}

const req = {
    url: 'https://example.com',
    // method: 'GET' as 'GET'
    method: 'GET'
} as const;

// handleRequest(req.url, req.method as 'GET')
handleRequest(req.url, req.method)


